package com.onlyxiahui.common.action.description;

import java.util.ArrayList;
import java.util.List;

import org.springframework.util.AntPathMatcher;

import com.onlyxiahui.common.action.description.box.ValidationDataBox;
import com.onlyxiahui.common.action.description.config.ScanConfig;
import com.onlyxiahui.common.action.description.handler.MethodHandler;
import com.onlyxiahui.common.action.description.handler.MethodTitleHandler;
import com.onlyxiahui.common.action.description.handler.ModuleHandler;
import com.onlyxiahui.common.action.description.handler.ModuleTitleHandler;
import com.onlyxiahui.common.action.description.handler.ParameterHandler;
import com.onlyxiahui.common.action.description.handler.ParameterValidateHandler;
import com.onlyxiahui.common.action.description.handler.PropertyHandler;
import com.onlyxiahui.common.action.description.handler.PropertyValidateHandler;
import com.onlyxiahui.common.action.description.handler.ResultHandler;
import com.onlyxiahui.common.action.description.source.SourceBox;
import com.onlyxiahui.common.action.description.support.DocClassScanner;
import com.onlyxiahui.common.action.description.support.IgnoreJudgeBox;

/**
 * 
 * <br>
 * Date 2019-11-04 17:49:15<br>
 * 
 * @author XiaHui [onlovexiahui@qq.com]<br>
 * @since 1.0.0
 */

public class DocumentContext {

	private ScanConfig scanConfig = new ScanConfig();
	private final SourceBox sourceBox = new SourceBox();
	private final List<ModuleHandler> moduleHandlers = new ArrayList<>();
	private final List<MethodHandler> methodHandlers = new ArrayList<>();

	private final List<ParameterHandler> parameterHandlers = new ArrayList<>();
	private final List<ParameterValidateHandler> parameterValidateHandlers = new ArrayList<>();

	private final List<PropertyHandler> propertyHandlers = new ArrayList<>();
	private final List<PropertyValidateHandler> propertyValidateHandlers = new ArrayList<>();

	private final List<ModuleTitleHandler> moduleTitleHandlers = new ArrayList<>();
	private final List<MethodTitleHandler> methodTitleHandlers = new ArrayList<>();

	private final List<ResultHandler> resultHandlers = new ArrayList<>();
	private final IgnoreJudgeBox ignoreJudgeBox = new IgnoreJudgeBox();

	private final ValidationDataBox validationDataBox = new ValidationDataBox();

	private final AntPathMatcher pathMatcher = new AntPathMatcher();

	private DocClassScanner docClassScanner;

	private final DocumentService documentService;

	public DocumentContext(DocumentService documentService) {
		this.documentService = documentService;
	}

	public ScanConfig getScanConfig() {
		return scanConfig;
	}

	public void setScanConfig(ScanConfig scanConfig) {
		this.scanConfig = scanConfig;
	}

	public SourceBox getSourceBox() {
		return sourceBox;
	}

	public void loadSource(String... paths) {
		sourceBox.load(paths);
	}

	public List<ModuleHandler> getModuleHandlers() {
		return moduleHandlers;
	}

	public List<MethodHandler> getMethodHandlers() {
		return methodHandlers;
	}

	public List<ParameterHandler> getParameterHandlers() {
		return parameterHandlers;
	}

	public List<ParameterValidateHandler> getParameterValidateHandlers() {
		return parameterValidateHandlers;
	}

	public List<PropertyHandler> getPropertyHandlers() {
		return propertyHandlers;
	}

	public List<PropertyValidateHandler> getPropertyValidateHandlers() {
		return propertyValidateHandlers;
	}

	public List<ModuleTitleHandler> getModuleTitleHandlers() {
		return moduleTitleHandlers;
	}

	public List<MethodTitleHandler> getMethodTitleHandlers() {
		return methodTitleHandlers;
	}

	public List<ResultHandler> getResultHandlers() {
		return resultHandlers;
	}

	public DocumentService getDocumentService() {
		return documentService;
	}

	public void addModuleHandler(ModuleHandler handler) {
		moduleHandlers.add(handler);
	}

	public void addMethodHandler(MethodHandler handler) {
		methodHandlers.add(handler);
	}

	public void addParameterHandler(ParameterHandler handler) {
		parameterHandlers.add(handler);
	}

	public void addParameterValidateHandler(ParameterValidateHandler handler) {
		parameterValidateHandlers.add(handler);
	}

	public void addPropertyHandler(PropertyHandler handler) {
		propertyHandlers.add(handler);
	}

	public void addPropertyValidateHandler(PropertyValidateHandler handler) {
		propertyValidateHandlers.add(handler);
	}

	public void addModuleTitleHandler(ModuleTitleHandler handler) {
		moduleTitleHandlers.add(handler);
	}

	public void addMethodTitleHandler(MethodTitleHandler handler) {
		methodTitleHandlers.add(handler);
	}

	public void addResultHandler(ResultHandler handler) {
		resultHandlers.add(handler);
	}

	public DocClassScanner getDocClassScanner() {
		return docClassScanner;
	}

	public void setDocClassScanner(DocClassScanner docClassScanner) {
		this.docClassScanner = docClassScanner;
	}

	public IgnoreJudgeBox getIgnoreJudgeBox() {
		return ignoreJudgeBox;
	}

	public ValidationDataBox getValidationDataBox() {
		return validationDataBox;
	}

	public AntPathMatcher getPathMatcher() {
		return pathMatcher;
	}

	public void clear() {
		sourceBox.clear();
	}
}
